﻿using ERP.ERPSystem.DataAnalysis;
using ERP.ERPSystem.WarehouseManagement.Dto;
using ERP.Team.ProductionSystem;
using ERP.Team.WarehouseManagement;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ERP.Web.Controllers.DataAnalysis
{
    /// <summary>
    /// 数据分析-库存数据-xzc
    /// </summary>
    public class InventoryDataController : Controller
    {
        private readonly IInventoryDataServices _inventoryDataServices;

        public InventoryDataController(IInventoryDataServices inventoryDataServices)
        {
            _inventoryDataServices = inventoryDataServices;
        }

        /// <summary>
        /// 库存数据视图
        /// </summary>
        /// <returns></returns>
        public IActionResult InventoryDataView()
        {
            return View();
        }
        /// <summary>
        /// 库存数据查询
        /// </summary>
        /// <param name="inventorydatadto"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<GetInventoryDataDto>> GetInventoryData(InventoryDataDto inventorydatadto)
        {
            var i = await _inventoryDataServices.GetInventoryData(inventorydatadto);
            return i;
        }
        /// <summary>
        /// 查询物料产品分类出局
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Inventory>> GetMaterialType()
        {
            var i = await _inventoryDataServices.GetMaterialType();
            return i;
        }

        [HttpGet]
        public async Task<JsonResult> GetInventoryChartData()
        {
            var result = await _inventoryDataServices.GetInventoryChartDataAsync();
            return Json(new { success = true, data = result });
        }

        [HttpGet]
        public async Task<JsonResult> GetInventoryPieChartData()
        {
            var result = await _inventoryDataServices.GetInventoryPieChartDataAsync();
            return Json(new { success = true, data = result });
        }

        [HttpGet]
        public async Task<JsonResult> GetInventoryStatistics()
        {
            var result = await _inventoryDataServices.GetInventoryStatisticsAsync();
            return Json(new { success = true, data = result });
        }
    }
}
